package com.example.finallyjob.Controllers;


import com.example.finallyjob.service.Comment;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "回复评论/作品回复/关注好友/点赞/警告")
@RestController
public class MessageController {
    @Autowired
    private Comment comments;

    @ApiOperation(value = "对某一个作品做回复",notes = "返回回复的id")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "name", value = "用户名", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "num", value = "作品文件的编号", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "comment", value = "回复的内容", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "title", value = "作品题目", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "作品类型（text||video）", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "auth", value = "作者id", required = true, dataType = "Int")
    })
    @PostMapping("/NewRely")
    public String NewRely(String name, String num, String comment,
    String title, String type, int auth){
        return comments.NewRely(name, num, comment, title, type, auth);
    }

    @ApiOperation(value = "对某一个作品下的某个回复做评论",notes = "返回更新后的评论列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "ReplyList", value = "回复的评论列表", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "num", value = "回复的id", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "name", value = "用户名", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "comment", value = "评论的内容", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "title", value = "作品题目", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "作品类型（text||video）", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "auth", value = "作品的作者id", required = true, dataType = "Int")
    })
    @PostMapping("/comment")
    public String comment(String num, String comment, String name, int auth,
                          String title, String type, String ReplyList){
        return comments.comment(num, comment, name,
                auth, title, type, ReplyList);
    }

    @ApiOperation(value = "对某一个作品的作者添加关注成为好友",notes = "返回更新后好友列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "用户id", required = true, dataType = "Int"),
            @ApiImplicitParam(paramType = "query", name = "name", value = "用户名", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "article", value = "作品文件的编号", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "friends", value = "用户的好友列表", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "auth_id", value = "作者id", required = true, dataType = "Int"),
            @ApiImplicitParam(paramType = "query", name = "auth_name", value = "作者名", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "作品类型（text||video）", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "title", value = "作品名称", required = true, dataType = "String")
    })
    @PostMapping("/follow")
    public String follow(int id,String name, String article,
    String friends, String title, String type, int auth_id, String auth_name){

        return comments.follow(id, name, article, friends, title,
                type, auth_id, auth_name);
    }

    @ApiOperation(value = "管理员对某一个作品进行警告",notes = "返回警告数量")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "name", value = "用户名", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "article", value = "作品文件的编号", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "auth", value = "作者id", required = true, dataType = "Int"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "作品类型（text||video）", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "title", value = "作品名称", required = true, dataType = "Int")
    })
    @PostMapping("/warning")
    public Boolean warning(String article, int auth, String name,
                           String title, String type) throws Exception {
        return comments.warning(article, auth, name, title, type);
    }

    @ApiOperation(value = "对某一个作品进行点赞",notes = "返回点赞数量")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "name", value = "用户名", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "article", value = "作品文件的编号", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "auth", value = "作者id", required = true, dataType = "Int"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "作品类型（text||video）", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "title", value = "作品名称", required = true, dataType = "String")
    })
    @PostMapping("/likes")
    public Integer likes(String article, String name, int auth,
                         String title, String type) throws Exception {
        return comments.likes(article, name, auth, title, type);
    }
}
